    {layout name="common/layout" /}
  
 
	<script type="text/javascript" src="__MERCHANT_STATIC__/style/js/umeditor/third-party/jquery.min.js"></script>
	<script type="text/javascript" src="__MERCHANT_STATIC__/style/js/umeditor/third-party/template.min.js"></script>
 
 
    <div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>
    <style>
	.div_borad{
	border:1px solid  #E8E8E8;
	width:300px;
	height:300px;
	}
	</style>
<div class="Hui-article-box" style="margin-top: 37px;">
	<div class="breadcrumb"><i class="Hui-iconfont"></i>商品
	<span class="c-gray en">&gt;</span> 添加商品详情模板 <span class="c-gray en">&gt;</span> 
	</div>
	<div class="Hui-article">
			<div style="height: 100px;border:1px solid #ccc;" class="mac">
				<div style="margin-left: 30px;">
					<h3>添加商品详情模板</h3>
					<span>商品/商品详情模板/<span style="font-weight: bold;font-size: 16px;">添加商品详情模板</span></span>
				</div>
			</div>
			<form action="" style="height: 700px;">
					<div class="mac" style="width: 920px;">
						<div style="padding:15px 0 0 30px;">
							<span>商品详情模板名称：</span>
							<input id="goods_details_name" type="text" name="goods_details_name" class="input-text radius size-M  ">
						</div>
						<div class="cl">
							<div class="f-l" style="margin-left: 30px;"><span>商品详情模板内容：</span></div>
							<div class="f-l" style="width:300px;height:300px;margin-left: 34px; border:1px solid  #E8E8E8;">
							            <div class="div_borad" >
							            <input type="hidden" value="" id="goods_details_content1" name="goods_details_content">
										
										<img id="img_goods" width="300px"   height="300px" src="__MERCHANT_STATIC__/style/img/upload_default.png"  onclick="$('#rentlist1').click()"/><br>
										<input  type="file" id="rentlist1" onchange="upload_goods_details('rentlist1')" name="imagefile1" style="margin-top: 10px; display:none;"/><br>
										<input  type="button" class="btn1" onclick="upload_goods_details('rentlist1');" value="上传"  style="margin:10px 0 20px 0px;display:none;"/>
							            </div>
										
										 
							 </div>
						</div>
						 <div style="padding:15px 0 0 30px;display:none;">
							<span>内容介绍：</span>
							<input id="goods_details_text" value="" type="text" name="goods_details_text" class="input-text radius size-M  ">
						</div>
						
						<div class="btn-l">
							<input id="submitBtn" type="button" value="保存"  class="btn" >
							<button onclick="returnlist()" class="btn" style="margin-left: 20px;padding-top: -20px;">返回</button>
						</div>				
				 	</div>
			</form>
	</div>
</div>
 
 
 
<script> 
      
    function returnlist()
	{
	location.href="{:url('goodsdetails/showlist')}";
	}
    $('#submitBtn').click(function(){
	    
	if($("#goods_details_name").val()=='') {	 
		layer.msg("商品详情模板名称不能为空!");
		$("#goods_details_name").focus();
		return ;
	 } 
	    var goods_details_name = $('input[name=goods_details_name]').val();
    	var goods_details_content = $("input[name='goods_details_content']").val();
		var goods_details_text = $('input[name=goods_details_text]').val();
		$.ajax({
          type: "POST",
          url: "<?php echo url('goodsdetails/insert', '', false); ?>",
          dataType: 'json',
          cache: false,
          data: {'goods_details_name': goods_details_name,'goods_details_content': goods_details_content,'goods_details_text': goods_details_text},
          success: function(data) {
            if(data.status == 1) 
            {
              layer.msg(data.msg,
              	{time:1000,end: function(index, layero){
   					location.href="{:url('goodsdetails/showlist')}";
   				 	layer.close(index); 
  				}});

            }else{
              layer.msg(data.msg);
            }

          },
          error: function(xhr, status, error) {
            console.log(xhr);
            console.log(status);
            console.log(error);
          }
        });
    });
    
   
function upload_goods_details( img_id ){
    var formData = new FormData();
	formData.append("file",$("#"+img_id+"")[0].files[0]);
	$.ajax({
		type:"post",
		url:"{:url('Goodsdetails/upload_img', '', false)}",
		async:true,
		cache: false,
	    data: formData,
	    processData: false,
	    contentType: false,
		data : formData,
		success : function(res){
	    	 $("#"+img_id+"").siblings("img").attr("src",res.data.access_url);
			 $("#"+img_id+"").siblings("img").siblings("input[type=hidden]").val(res.data.filename);
		},
		error : function(res){
			console.log(res.access_url);
			 
		}


	});
}

    
</script>
 